package com.bestom.smartwatch.callBack;

import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.bestom.smartwatch.util.ConversionUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import static com.bestom.smartwatch.util.LogUtil.log;

public class IServiceCallback extends com.sxr.sdk.ble.keepfit.aidl.IServiceCallback.Stub {

    private static final String TAG = "IServiceCallback";
    @Override
    public void onConnectStateChanged(int state) throws RemoteException {
        log("onConnectStateChanged",  " state " + state);
    }


    @Override
    public void onScanCallback(final String deviceName, final String deviceMacAddress, final int rssi)
            throws RemoteException {
        Log.d("iiii","iiiiiiiiiiiiiiiiiii");
        log("onScanCallback", String.format("onScanCallback <%1$s>[%2$s](%3$d)", deviceName, deviceMacAddress, rssi));

    }


    @Override
    public void onSetNotify(int result) throws RemoteException {
        log("onSetNotify", String.valueOf(result));
    }

    @Override
    public void onSetUserInfo(int result) throws RemoteException {
        log("onSetUserInfo", "" + result);
    }

    @Override
    public void onAuthSdkResult(int errorCode) throws RemoteException {
        log("onAuthSdkResult", errorCode + "");
    }

    @Override
    public void onGetDeviceTime(int result, String time) throws RemoteException {
        log("onGetDeviceTime", String.valueOf(time));
    }

    @Override
    public void onSetDeviceTime(int arg0) throws RemoteException {
        log("onSetDeviceTime", arg0 + "");
    }

    @Override
    public void onSetDeviceInfo(int arg0) throws RemoteException {
        log("onSetDeviceInfo", arg0 + "");
    }


    @Override
    public void onAuthDeviceResult(int arg0) throws RemoteException {
        log("onAuthDeviceResult", arg0 + "");
    }


    @Override
    public void onSetAlarm(int arg0) throws RemoteException {
        log("onSetAlarm", arg0 + "");
    }

    @Override
    public void onSendVibrationSignal(int arg0) throws RemoteException {
        log("onSendVibrationSignal", "result:" + arg0);
    }

    @Override
    public void onGetDeviceBatery(int arg0, int arg1)
            throws RemoteException {
        log("onGetDeviceBatery", "batery:" + arg0 + ", statu " + arg1);
    }


    @Override
    public void onSetDeviceMode(int arg0) throws RemoteException {
        log("onSetDeviceMode", "result:" + arg0);
    }

    @Override
    public void onSetHourFormat(int arg0) throws RemoteException {
        log("onSetHourFormat ", "result:" + arg0);

    }

    @Override
    public void setAutoHeartMode(int arg0) throws RemoteException {
        log("setAutoHeartMode ", "result:" + arg0);
    }


    @Override
    public void onGetCurSportData(int type, long timestamp, int step, int distance,
                                  int cal, int cursleeptime, int totalrunningtime, int steptime) throws RemoteException {
        Date date = new Date(timestamp * 1000);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String time = sdf.format(date);
        log("onGetCurSportData", "type : " + type + " , time :" + time + " , step: " + step + ", distance :" + distance + ", cal :" + cal + ", cursleeptime :" + cursleeptime + ", totalrunningtime:" + totalrunningtime);
    }

    @Override
    public void onGetSenserData(int result, long timestamp, int heartrate, int sleepstatu)
            throws RemoteException {
        Date date = new Date(timestamp * 1000);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String time = sdf.format(date);
        log("onGetSenserData", "result: " + result + ",time:" + time + ",heartrate:" + heartrate + ",sleepstatu:" + sleepstatu);

    }


    @Override
    public void onGetDataByDay(int type, long timestamp, int step, int heartrate)
            throws RemoteException {
        Date date = new Date(timestamp * 1000);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String recorddate = sdf.format(date);
        log("onGetDataByDay", "type:" + type + ",time::" + recorddate + ",step:" + step + ",heartrate:" + heartrate);

    }

    @Override
    public void onGetDataByDayEnd(int type, long timestamp) throws RemoteException {
        Date date = new Date(timestamp * 1000);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String recorddate = sdf.format(date);
        log("onGetDataByDayEnd", type + " time:" + recorddate);

    }


    @Override
    public void onSetPhontMode(int arg0) throws RemoteException {
        log("onSetPhontMode", "result:" + arg0);
    }


    @Override
    public void onSetSleepTime(int arg0) throws RemoteException {
        log("onSetSleepTime", "result:" + arg0);
    }


    @Override
    public void onSetIdleTime(int arg0) throws RemoteException {
        log("onSetIdleTime", "result:" + arg0);
    }


    @Override
    public void onGetDeviceInfo(int version, String macaddress, String vendorCode,
                                String productCode, int result) throws RemoteException {
        log("onGetDeviceInfo", "version :" + version + ",macaddress : " + macaddress + ",vendorCode : " + vendorCode + ",productCode :" + productCode + " , CRCresult :" + result);

    }

    @Override
    public void onGetDeviceAction(int type) throws RemoteException {
        log("onGetDeviceAction", "type:" + type);

    }


    @Override
    public void onGetBandFunction(int result, boolean[] results) throws RemoteException {
        log("onGetBandFunction", "result : " + result + ", results :" + results.length);

        String function = "";
        for (int i = 0; i < results.length; i++) {
            function += String.valueOf((i + 1) + "=" + results[i] + " ");
        }
        log("onGetBandFunction", function);
    }

    @Override
    public void onSetLanguage(int arg0) throws RemoteException {
        log("onSetLanguage", "result:" + arg0);

    }


    @Override
    public void onSendWeather(int arg0) throws RemoteException {
        log("onSendWeather", "result:" + arg0);
    }


    @Override
    public void onSetAntiLost(int arg0) throws RemoteException {
        log("onSetAntiLost", "result:" + arg0);

    }


    @Override
    public void onReceiveSensorData(int arg0, int arg1, int arg2, int arg3,
                                    int arg4) throws RemoteException {
        log("onReceiveSensorData", "result:" + arg0 + " , " + arg1 + " , " + arg2 + " , " + arg3 + " , " + arg4);
    }


    @Override
    public void onSetBloodPressureMode(int arg0) throws RemoteException {
        log("onSetBloodPressureMode", "result:" + arg0);
    }


    @Override
    public void onGetMultipleSportData(int flag, String recorddate, int mode, int value)
            throws RemoteException {

        log("onGetMultipleSportData", "flag:" + flag + " , mode :" + mode + " recorddate:" + recorddate + " , value :" + value);
    }


    @Override
    public void onSetGoalStep(int result) throws RemoteException {
        log("onSetGoalStep", "result:" + result);
    }


    @Override
    public void onSetDeviceHeartRateArea(int result) throws RemoteException {
        log("onSetDeviceHeartRateArea", "result:" + result);
    }


    @Override
    public void onSensorStateChange(int type, int state)
            throws RemoteException {

        log("onSensorStateChange", "type:" + type + " , state : " + state);
    }

    @Override
    public void onReadCurrentSportData(int mode, String time, int step,
                                       int cal) throws RemoteException {

        log("onReadCurrentSportData", "mode:" + mode + " , time : " + time + " , step : " + step + " cal :" + cal);
    }

    @Override
    public void onGetOtaInfo(boolean isUpdate, String version, String path) throws RemoteException {
        log("onGetOtaInfo", "isUpdate " + isUpdate + " version " + version + " path " + path);
    }

    @Override
    public void onGetOtaUpdate(int step, int progress) throws RemoteException {
        log("onGetOtaUpdate", "step " + step + " progress " + progress);
    }

    @Override
    public void onSetDeviceCode(int result) throws RemoteException {
        log("onSetDeviceCode", "result " + result);
    }

    @Override
    public void onGetDeviceCode(byte[] bytes) throws RemoteException {
        log("onGetDeviceCode", "bytes " + ConversionUtil.getInstance().printHexString(bytes));
    }

    @Override
    public void onCharacteristicChanged(String uuid, byte[] bytes) throws RemoteException {
        log("onCharacteristicChanged", uuid + " " + ConversionUtil.getInstance().printHexString(bytes));
    }

    @Override
    public void onCharacteristicWrite(String uuid, byte[] bytes, int status) throws RemoteException {
        log("onCharacteristicWrite", status + " " + uuid + " " + ConversionUtil.getInstance().printHexString(bytes));
    }

    @Override
    public void onSetEcgMode(int result, int state) throws RemoteException {
        log("onSetEcgMode", "result " + result + " state " + state);
    }

    @Override
    public void onGetEcgValue(int state, int[] values) throws RemoteException {
        log("onGetEcgValue", "state " + state + " value " + values.length);

    }

    @Override
    public void onGetEcgHistory(long timestamp, int number) throws RemoteException {
        log("onGetEcgHistory", "timestamp " + timestamp + " number " + number);

    }

    @Override
    public void onGetEcgStartEnd(int id, int state, long timestamp) throws RemoteException {
        log("onGetEcgStartEnd", "id " + id + " state " + state + " timestamp " + timestamp);

    }

    @Override
    public void onGetEcgHistoryData(int id, int[] values) throws RemoteException {
        log("onGetEcgHistoryData", "id " + id + " values " + values.length);

    }

    @Override
    public void onSetDeviceName(int result) throws RemoteException {
        log("onSetDeviceName", "result " + result);
    }

    @Override
    public void onGetDeviceRssi(int rssi) throws RemoteException {
        log("onGetDeviceRssi", "rssi " + rssi);

    }

    @Override
    public void onSetReminder(int result) throws RemoteException {
        log("onSetReminder", "result " + result);

    }

    @Override
    public void onSetReminderText(int result) throws RemoteException {
        log("onSetReminderText", "result " + result);

    }

    @Override
    public void onSetBPAdjust(int result) throws RemoteException {
        log("onSetBPAdjust", "result " + result);

    }

    @Override
    public void onSetTemperatureMode(int result) throws RemoteException {
        log("onSetTemperatureMode", "result " + result);

    }

    @Override
    public void onGetTemperatureData(int surfaceTemp,int bodyTemp) throws RemoteException {
        log("onGetTemperatureData", "surfaceTemp " + surfaceTemp + ", bodyTemp" + bodyTemp);

    }

    @Override
    public void onTemperatureModeChange(int enable) throws RemoteException {
        log("onTemperatureModeChange", "enable " + enable);
    }

    @Override
    public IBinder asBinder() {
        return null;
    }
}
